//
//  MyMainViewController.m
//  Nidalee
//
//  Created by neobug on 2020/12/1.
//  Copyright © 2020 李康. All rights reserved.
//

#import "MyMainViewController.h"

#import "MyUserCell.h"
#import "MyMoreCell.h"

@interface MyMainViewController () <UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataSource;

@end

@implementation MyMainViewController



#pragma mark - Public Method

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initAllPropertys];
    [self setupUI];
    [self queryData];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.hidesBottomBarWhenPushed = NO;
}
- (void)dealloc {
    NSLog(@"%s",__func__);
}
#pragma mark - Data Query
- (void)queryData {
    [self.dataSource addObject:@{}];
    [self.dataSource addObject:@{@"title":@"消息中心", @"img":@"My_msg.png"}];
    [self.dataSource addObject:@{@"title":@"我的评论", @"img":@"My_pinglun.png"}];
    [self.dataSource addObject:@{@"title":@"我的屏蔽", @"img":@"My_pingbi.png"}];
    [self.dataSource addObject:@{@"title":@"我的选股", @"img":@"My_pingbi.png"}];
    [self.tableView reloadData];
}
#pragma mark - Notification

#pragma mark - UI
- (void)initAllPropertys {
    self.title = @"我的";
}

- (void)setupUI {
    self.tableView.tableFooterView = [UIView new];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"MyUserCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyUserCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"MyMoreCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyMoreCell"];
    
}
#pragma mark - Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        MyUserCell *cell = (MyUserCell *)[tableView dequeueReusableCellWithIdentifier:@"MyUserCell" forIndexPath:indexPath];
        return cell;
    }else {
        NSDictionary *dic = self.dataSource[indexPath.row];
        MyMoreCell *cell = (MyMoreCell *)[tableView dequeueReusableCellWithIdentifier:@"MyMoreCell" forIndexPath:indexPath];
        cell.dic = dic;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 200;
    }
    return 55;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - Private Method

#pragma mark - Overwrite Method

#pragma mark - Event Response

- (IBAction)clickOut:(id)sender {
    NSLog(@"点击退出");
}
#pragma mark - Setter

#pragma mark - Getter
- (NSMutableArray *)dataSource {
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}

@end
